package com.wanghlme.leetcodecn;

/**
 * <p>剑指 Offer 53 - II. 0～n-1中缺失的数字</p>
 *
 * @author wanghlme
 * @version 1.0
 */
public class LC_JZ53_2 {
    public static void main(String[] args) {
        System.out.println(new Solution().missingNumber(new int[]{0, 1, 3}));
    }

    static class Solution {
        public int missingNumber(int[] nums) {
            int i = 0, j = nums.length - 1;
            while (i <= j) {
                int m = (i + j) / 2;
                if (nums[m] == m) i = m + 1;
                else j = m - 1;
            }
            return i;
        }
    }
}
